package com.yuan.model_app.rest;

import com.yuan.model_app.rest.resp.PaymentInfoResp;
import com.yuan.model_app.rest.resp.UserHouseInfoResp;
import com.yuan.model_app.service.UserAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "物业便民: APP模块")
@RestController
@RequestMapping("/api/app")
@RequiredArgsConstructor
public class UserAppController {

    private final UserAppService userAppService;

    @GetMapping("/finUserHouseInfo")
    @Log("查询/api/user/house/info")
    @ApiOperation("查询/user/house/info")
    public ResponseEntity<UserHouseInfoResp> queryUserHouseInfoList(@RequestParam Long userId) {
        UserHouseInfoResp userHouseInfoResp = userAppService.userHouseInfo(userId);
        return new ResponseEntity<>(userHouseInfoResp, HttpStatus.OK);
    }

    @GetMapping("/finUserPaymentInfo")
    @Log("查询/api/user/payment/info")
    @ApiOperation("查询/user/payment/info")
    public ResponseEntity<List<PaymentInfoResp>> finUserPaymentInfo(@RequestParam Long userId, @RequestBody Pageable pageable) {
        List<PaymentInfoResp> paymentInfoResps = userAppService.paymentCountInfo(userId, pageable);
        return new ResponseEntity<>(paymentInfoResps, HttpStatus.OK);
    }

}
